/**
 * @Author:Geln Yang
 * @Created:2008-8-3
 * $ Revision: 1.0 $
 * $ Author: Geln Yang $
 * $ Date: 2008-8-3 $
 */
package com.hgy.commonsale.webui.context.impl;

import org.geln.web.context.impl.SessionContextImpl;

import com.hgy.commonsale.service.IUserManager;
import com.hgy.commonsale.user.domain.User;
import com.hgy.commonsale.webui.context.IApplicationSessionContext;

/**
 * @Author:Geln Yang
 * @Created:2008-8-3
 */
public class ApplicationSessionContextImpl extends SessionContextImpl implements IApplicationSessionContext {

	private IUserManager userManager;

	public User getUser() {
		String userId = getAccount();
		return getUser(userId);
	}

	private User getUser(String id) {
		if (id == null || id.length() == 0) {
			return null;
		}
		return userManager.getUserById(id);
	}

	public void clearContext(String userId) {
		super.clearContext(userId);
	}

	public void setUserManager(IUserManager userManager) {
		this.userManager = userManager;
	}

}
